﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display {
    import flash.events.*;
    import flash.display.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import Display.aswingui.*;
    import L10n.*;

    public class ToolTipDialog extends GenericDialog {

        public static const HEADER:String = "header";
        public static const NOTES:String = "notes";
        public static const STATUS:String = "status";
        public static const ACTION:String = "action";

        protected var m_hasData:Boolean;
        protected var m_header:String;
        protected var m_notes:String;
        protected var m_status:String;
        protected var m_action:String;
        protected var m_titleString:String;
        protected var m_schema:ToolTipSchema;
        protected var m_components:Array;
        protected var m_previousTarget:IToolTipTarget;

        public function ToolTipDialog(_arg1:String, _arg2:String="", _arg3:int=0, _arg4:Function=null, _arg5:Boolean=true){
            this.m_components = new Array();
            this.m_schema = ToolTipSchema.TOOLTIP_SCHEMA_DEFAULT;
            super(_arg1, _arg2, _arg3, _arg4, _arg2, "", false);
            this.m_header = null;
            this.m_notes = null;
            this.m_status = null;
            this.m_action = null;
            this.mouseChildren = (this.mouseEnabled = false);
        }
        override protected function init():void{
            m_holder = new Sprite();
            this.addChild(m_holder);
            this.m_hasData = ((!((m_message == null))) && (!((m_message == ""))));
            m_jwindow = new JWindow(m_holder);
            m_content = m_holder;
            m_content.addEventListener("close", closeMe, false, 0, true);
            m_content.addEventListener(MouseEvent.MOUSE_MOVE, this.removePopup, false, 0, true);
        }
        override protected function doTrackDialogActions():Boolean{
            return (false);
        }
        override protected function loadAssets():void{
            onAssetsLoaded();
        }
        override protected function createAssetDict():Dictionary{
            return (new Dictionary());
        }
        override protected function createDialogView(_arg1:Dictionary):GenericDialogView{
            return (new ToolTipDialogView(_arg1, this.m_schema, m_message, m_title, m_type, m_callback));
        }
        protected function removePopup(_arg1:MouseEvent):void{
            Global.ui.hideAnyToolTip();
        }
        public function setToolTipSchema(_arg1:ToolTipSchema):void{
            if (_arg1 != this.m_schema){
                this.m_schema = _arg1;
                (m_jpanel as ToolTipDialogView).refreshSchemaFormatting(this.m_schema);
            };
        }
        public function loadToolTipForTarget(_arg1:IToolTipTarget):void{
            var _local2:Array;
            var _local3:Array;
            var _local4:*;
            var _local5:Boolean;
            var _local6:String;
            var _local7:int;
            if ((_arg1 is ICustomToolTipTarget)){
                _local2 = (_arg1 as ICustomToolTipTarget).getToolTipComponentList();
                _local3 = [];
                for each (_local4 in _local2) {
                    if ((_local4 is Component)){
                        _local3.push(_local4);
                    };
                };
                _local5 = false;
                if (this.m_components.length != _local3.length){
                    _local5 = true;
                } else {
                    _local7 = 0;
                    while (_local7 < this.m_components.length) {
                        if (this.m_components[_local7] != _local3[_local7]){
                            _local5 = true;
                            break;
                        };
                        _local7++;
                    };
                };
                if (_local5){
                    this.m_components = _local3;
                    (m_jpanel as ToolTipDialogView).setCustomComponentsList(this.m_components);
                };
                _local6 = (_arg1 as ICustomToolTipTarget).getCustomToolTipTitle();
                if (((!((_local6 == this.m_titleString))) || (!((this.m_previousTarget == _arg1))))){
                    this.m_titleString = _local6;
                    LocaleHelper.localSetting.TextField_adjust((m_jpanel as ToolTipDialogView).getJTextField().getTextField(), {
                        embedFonts:false,
                        font:EmbeddedArt.SYSTEM_FONT
                    });
                    (m_jpanel as ToolTipDialogView).setTitle(this.m_titleString);
                };
                (m_jpanel as ToolTipDialogView).setImage((_arg1 as ICustomToolTipTarget).getCustomToolTipImage());
                this.m_header = null;
                this.m_status = null;
                this.m_notes = null;
                this.m_action = null;
            } else {
                if (_arg1 != null){
                    this.setStatus(_arg1.getToolTipStatus());
                    this.setHeader(_arg1.getToolTipHeader());
                    this.setNotes(_arg1.getToolTipNotes());
                    this.setCallToAction(_arg1.getToolTipAction());
                    (m_jpanel as ToolTipDialogView).setLegacyComponentsList(_arg1);
                    this.m_titleString = null;
                    this.m_components = new Array();
                };
            };
            (m_jpanel as ToolTipDialogView).finalize();
            this.m_previousTarget = _arg1;
        }
        public function hasData():Boolean{
            return (((((((((((((this.m_header) && (!((this.m_header == ""))))) || (((this.m_notes) && (!((this.m_notes == ""))))))) || (((this.m_status) && (!((this.m_status == ""))))))) || (((this.m_action) && (!((this.m_action == ""))))))) || ((this.m_components.length > 0)))) || (this.m_titleString)));
        }
        public function setHeader(_arg1:String):void{
            if (((!((_arg1 == this.m_header))) || ((_arg1 == null)))){
                this.m_header = _arg1;
                (m_jpanel as ToolTipDialogView).setHeader(_arg1);
                LocaleHelper.localSetting.TextField_adjust((m_jpanel as ToolTipDialogView).getJTextField().getTextField(), {
                    embedFonts:false,
                    font:EmbeddedArt.SYSTEM_FONT,
                    size:16
                });
                ASwingHelper.prepare(m_jwindow);
            };
        }
        public function setNotes(_arg1:String):void{
            if (((!((_arg1 == this.m_notes))) || ((_arg1 == null)))){
                this.m_notes = _arg1;
                (m_jpanel as ToolTipDialogView).setNotes(_arg1);
                ASwingHelper.prepare(m_jwindow);
            };
        }
        public function setStatus(_arg1:String):void{
            if (_arg1 == ZLoc.t("Main", "NoGoods")){
                this.m_status = _arg1;
                (m_jpanel as ToolTipDialogView).setStatus(_arg1, 16729156);
                ASwingHelper.prepare(m_jwindow);
            };
            if (((!((_arg1 == this.m_status))) || ((_arg1 == null)))){
                this.m_status = _arg1;
                (m_jpanel as ToolTipDialogView).setStatus(_arg1);
                ASwingHelper.prepare(m_jwindow);
            };
        }
        public function setCallToAction(_arg1:String):void{
            if (((!((_arg1 == this.m_action))) || ((_arg1 == null)))){
                this.m_action = _arg1;
                (m_jpanel as ToolTipDialogView).setCallToAction(_arg1);
                ASwingHelper.prepare(m_jwindow);
            };
        }

    }
}//package Display 
